#!/usr/bin/env python

import sys
import ConfigParser
import MySQLdb
import math

def getConfig(path):
	config = ConfigParser.RawConfigParser()
	config.read(path)
	return config

def getCursor(config):
	conn = MySQLdb.connect (host = getDBHost(config),
                        port = getDBPort(config),
                        user = getDBUser(config),
                        passwd = getDBPassword(config),
                        db = getDBSchema(config))
	return conn.cursor()

def getDBHost(config):
	return config.get("mysql_configs", "host") #myhost

def getDBPort(config):
	return int(config.get("mysql_configs", "port")) #myport

def getDBSchema(config):
	return config.get("mysql_configs", "db")

def getDBUser(config):
	return config.get("mysql_configs", "username")

def getDBPassword(config):
	return config.get("mysql_configs", "password")

def isUnmappedAssociation(f1alias, f2alias):
        """
        Classify edges as unmapped if both nodes do not have chr positions
        """
        f1data = f1alias.split(":")
        if (len(f1data) < 5):
                return False
        f1source = f1data[1]
        f1chr = f1data[3]
        f2data = f2alias.split(":")
        f2source = f2data[1]
        f2chr = f2data[3]
	
	if (f1chr == "" and f2chr == ""):
		return True
	
	"""
        if (f1chr == "" and (f1source != "CLIN" and f1source != "SAMP")):
                if (f2source != "CLIN" and f2source != "SAMP"):
                        return True
        if (f2chr == "" and (f2source != "CLIN" and f2source != "SAMP")):
                if (f1source != "CLIN" and f1source != "SAMP"):
                        return True
	"""
        return False


def is_numeric(val):
	try:
		float(val)
	except ValueError, e:
		return False        
	return True

#quick function to tell sign of int
sign = lambda x: math.copysign(1, x)
		
if __name__ == "__main__":	
	configfile = sys.argv[1]
	config = getConfig(configfile)
	
	"""
	myhost = config.get("mysql_configs", "host")
	myport = int(config.get("mysql_configs", "port"))
	mydb = config.get("mysql_configs", "db")
	myuser = config.get("mysql_configs", "username")
	mypw = config.get("mysql_configs", "password")
	cancer_type_list = config.get("cancer_types", "list").split(",")
	results_path = config.get("results", "path")
